<template>
  <div class="app-container calendar-list-container">
    <!-- 搜索工具栏 -->
    <section>
      <so-tool-bar :toolData="toolData" :query="listQuery" @search="search"/>
    </section>
    <!-- 其他操作 -->
    <section class="filter-container">
      <el-row>
        <el-col :span="6" style="padding-top: 5px;">
          &nbsp;&nbsp;<span class="el-green">共计&nbsp;<em>{{listQuery.total}}</em>&nbsp;条</span>
        </el-col>
      </el-row>
    </section>
    <!-- 表格 -->
    <el-table :data="dataList" v-loading="loading" element-loading-text="正在查询中。。。" stripe highlight-current-row>
      <el-table-column type="index" width="50" align="center"/>
      <el-table-column prop="action" align="center" label="行为">
        <template slot-scope="scope">
          {{conf.actionList[scope.row.action - 1]}}
        </template>
      </el-table-column>
      <el-table-column prop="module" align="center" label="模块">
        <template slot-scope="{row}">
          {{ conf.module[row.module] }}
        </template>
      </el-table-column>
      <el-table-column prop="behavior_desc" align="center" label="行为描述"/>
      <el-table-column label="操作人/ID" align="center">
        <template slot-scope="scope">
          {{ scope.row.user_name }} / {{ scope.row.user_id }}
        </template>
      </el-table-column>
      <el-table-column prop="create_time" align="center" label="操作时间"/>
      <el-table-column label="分数" align="center">
        <template slot-scope="scope">
          <p>{{ scope.row.score }}</p>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <section>
      <so-pagination :query="listQuery" @initList="initList"/>
    </section>
  </div>
</template>
<script>
import { searchTool } from '@/utils'
import { get_UserlogList } from "@/api/userlog";
import SoPagination from '@/components/SoPagination'
import SoToolBar from '@/components/SoToolBar'
import { toolData } from './userLog'
import config from '@/utils/conf'

export default {
  name: "userLog",
  components: { SoPagination, SoToolBar },
  data() {
    return {
      toolData: toolData, //搜索工具栏初始化
      loading: false,
      listQuery: { start: 0, limit: 10, total: 0, current: 1 },
      conf: config,
      currentPage: 1,
      dataList: []
    };
  },
  methods: {
    search() {//搜索
      let keyWords = {key: 'searchDate', names: ['create_starttime', 'create_endtime']}
      this.listQuery = searchTool(this.listQuery, keyWords);
      this.initList();
    },
    async initList() {//获取数据
      this.loading = true;
      const query = {...this.listQuery, company_id: localStorage.getItem("companyId") - 0}
      const { data } = await get_UserlogList(query);
      this.loading = false;
      if (data.status == 100) {
        this.dataList = data.data.rows;
        this.listQuery.total = data.data.results;
      }
    }
  },
  created() {
    this.initList();
  }
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
$color: #606266;
span {
  font-size: 13px;
  color: $color;
}
</style>
